//后台用户
$.fn.dataTable.ext.errMode = 'none'; //不显示任何错误
var DocData={
    userStatus:0,
    sysUserId:baseFn.getQueryString('userId',true),
    startDate:baseFn.getQueryString('startDate',true),
    endDate:baseFn.getQueryString('endDate',true),
    initStarDetail:function(data){
        var _data = data;
        var _stars=[_data.replyIntegral,_data.gentleIntegral,_data.serviceIntegral
            ,_data.subclinicIntegral
        ]
        $('.js_gradeNumber .star').removeClass('active')
        $('.js_gradeNumber').each(function(v,n){
            $(n).find('.star').each(function(k,m){
                var _x = Number($(m).data('ids'))+1;
                if(_x == _stars[v]){
                    $(m).trigger('click')
                }
            })
        })
        $('.starWrap textarea').val(_data.replyInfo)
    }
}
/* 查看详情 */
if(baseFn.getQueryString('userId') != null && $('.js_sysuserdetail').length == 1){
    $.get(baseUrl.base+baseUrl.sysuser+"detail",{userId:baseFn.getQueryString('userId')},function(res){
        if(res.code == 0){
            var _data = res.results
            $('.js_userRole').text(_data.roleName)
            $('.js_userLevel').text(_data.gradeName)
            var _starTxt=''
            for(var i=0;i<5;i++){
                if(_data.avgReply >i){
                    _starTxt +='<span class="star active"></span>'
                }else{
                    _starTxt +='<span class="star"></span>'
                }
            }
            $('.js_gradeNumber').html(_starTxt)
            if(_data.userImg != '' && _data.userImg != undefined && _data.userImg != null){
                var _img = new Image()
                _img.src = _data.userImg
                _img.onload=function(){
                    if(_img.width/_img.height >1){
                        $('.js_userImg').css({'background-size':'auto 100%','background-image':'url('+_data.userImg+')'})
                    }else{
                        $('.js_userImg').css({'background-size':'100% auto','background-image':'url('+_data.userImg+')'})
                    }
                }
            }
            
            $('.js_userName').text(_data.userName)  
            $('.js_userNo').text(_data.userNo)  
            $('.js_userPhone').text(_data.userPhone)  
            $('.js_subclinicName').text(_data.subclinicName)  
        }else{
            baseFn.infoDialog(res.info)
        }
    },'json')
    //辞退
    function dismiss() {
        //alert("辞退");
        if(baseFn.getPower(37)){//员工管理 辞退员工
            return false
        }
        baseFn.dialog({
            title:'提示',
            content:"您确定辞退该员工么？",
            ok:function(){
                baseFn.$post({
                    url:baseUrl.sysuser+"recovery",
                    data:{userId:baseFn.getQueryString('userId'),userStatus:2},
                    canNull:true,
                    calFn:function(res){
                        baseFn.infoDialog('辞退成功',function(){
                            baseFn.goPath('gotoCtaffManagement_q')
                        })

                    }
                })
            },
            cancel:function(){}
        })
    }
    //离职
    function resign() {
        //alert("离职");
        if(baseFn.getPower(39)){//员工管理 员工离职
            return false
        }
        baseFn.dialog({
            title:'提示',
            content:"您确定为该员工办理离职手续么？",
            ok:function(){
                baseFn.$post({
                    url:baseUrl.sysuser+"recovery",
                    data:{userId:baseFn.getQueryString('userId'),userStatus:1},
                    canNull:true,
                    calFn:function(res){
                        baseFn.infoDialog('离职成功',function(){
                            baseFn.goPath('gotoCtaffManagement_q')
                        })
                    }
                })
            },
            cancel:function(){}
        })
    }
    //修改密码
    function modify_password() {
        //alert("重置密码");
        baseFn.dialog({
            title:'提示',
            content:"您确定为该员工重置登录密码么？",
            ok:function(){
                baseFn.$post({
                    url:"resetUserPwd",
                    data:{userId:baseFn.getQueryString('userId')},
                    canNull:true,
                    calFn:function(res){
                        baseFn.infoDialog('重置成功')
                    }
                })
            },
            cancel:function(){}
        })
    }
    
    //查看评分详情
    function show_comments_detail() {
        var userId = baseFn.getQueryString('userId');
        baseFn.goPath('gotoSysUserReplyInfo',{userId:userId})
    }
}
/* 查看详情 */
/*员工绩效*/
if($('.js_sysuser_achievement').length == 1){
    var achievementDay ='',achievementMonth=''
    /* 控件*/
    var _date=new Date(),_curYear=_date.getFullYear();
    var _nextyear = Number(_curYear)+3,_prevyear=Number(_curYear)-3,_yearArr=[],_month=[]
    for(var i=_prevyear;i<_nextyear;i++){
        _yearArr.push({id:i,text:i})
    }
    for(var j=1;j<13;j++){
        var _time = baseFn.formatDate(j)
        _month.push({id:_time,text:_time+'月'})
    }
    baseFn.rpSelect('.timeyear',{
        datas:_yearArr,
        calFn:function(dom){
            dom.val(_yearArr[3].id).trigger('change')
        },
        selFn:function(){
            detailSearching()
        }
    })
    baseFn.rpSelect('.timemonth',{
        datas:_month,
        calFn:function(dom){
            dom.val(_month[_date.getMonth()].id).trigger('change')
        },
        selFn:function(){
            detailSearching()
        }
    })
    baseFn.rpSelect('.subclinic',{
        url:baseUrl.base+baseUrl.subclinic+'selectSubclinicList',
        idKey:'subclinicId',
        textKey:'subclinicName',
        calFn:function(){
            //权限管理 45 全部门店
            if(SessionData.powerSub){
                $(".subclinic").val(SessionData.powerSub).trigger('change')
            }
        },
        selFn:function(){
            detailSearching()
        }
    })
    //时间控件初始化
    baseFn.dateTimePickGroup('.datetimegroup',{
        startseled:function(){
            detailSearching()
        },
        endseled:function(){
            detailSearching()
        }
    })
    $('#startDate').val(baseFn.timestampToTime(Date.parse(new Date())).substring(0,10))
    $('#endDate').val(baseFn.timestampToTime(Date.parse(new Date())).substring(0,10))
    $('select.timetype').on('change',function(){
        detailSearching()
    })
    /* 控件*/
    function detailSearching(){
        var _updata = {
            subclinicId:SessionData.powerSub?SessionData.powerSub:$('select[name=subclinic]').val(),
            startDate:$('#startDate').val(),
            endDate:$('#endDate').val(),
            isMain:$('.timetype').val()
        } 
        if(_updata.isMain == 0){
            // 日
            $('.js_achievement_month_wrap').addClass('hidden')
            $('.js_achievement_day_wrap').removeClass('hidden')
            $('.js_day_timewrap').removeClass('hiddenim')
            $('.js_month_timewrap').addClass('hiddenim')
            if(achievementDay == ''){
                achievementDay = baseFn.rpDataTables('.js_achievement_day_list',{
                    ajUrl:baseUrl.base+baseUrl.sysuser+'selectUserDaySaleList',
                    ajDataSrc:"results",
                    ajData:_updata,
                    select:true,
                    ajType:'post',
                    scrollY:windowOffsetData.tableHeight(),
                    columns:[
                        // {"data":null,defaultContent:'',className:'select-checkbox'},
                        { "data": "userNo",defaultContent:'',className:'imgpwrap img2p',render:function(data,type,row, meta){
                            var _img=baseUrl.tempHeadImg
                            if(baseFn.notNull(row.userImg)){
                                _img = row.userImg
                            }
                            return '<div class="datatable_img_div" data-vals="'+_img+'" style="background-image:url('+_img+')"></div>\
                                                    <div class="pwrap">\
                                                        <span>'+data+'</span>\
                                                        <span>'+row.userName+'</span>\
                                                    </div>'
                        }},
                        { "data": "subclinicName",defaultContent:'无'},
                        { "data": "orderPayCost",defaultContent:'无'},
                        { "data": "doctorCost",defaultContent:'无'},
                        { "data": "userId",defaultContent:'无',width:'10%',render:function(data,type,row, meta){
                            return '<a class="datatablebtn detail" href="javascript:void(0)" data-vals="'+data+'">明细</a>';
                
                        }}
                    ],
                    initComplete:function(){
                    },
                    drawCallback: function( settings ) {
                        $('.detail').off('click').on('click',function(){
                            zcEditData('edit')
                            var _id = $(this).data('vals')
                            baseFn.goPath('gotoCtaffManagementDetail',{userId:_id,startDate:$('#startDate').val(),endDate:$('#endDate').val()})
                        })
                        //图片初始化
                        $('.js_achievement_day_list .datatable_img_div').each(function(ids,val){
                            baseFn.imgSize({
                                src: $(val).data('vals'),
                                hFn: function(res) {
                                      res.dom.css({'background-size':'auto 100%'})           
                                },
                                wFn: function(res) {
                                    res.dom.css({'background-size':'100% auto'}) 
                                },
                                ratio: 1,
                                otherData: {
                                    dom:$(val)
                                }
                            })
                        })
                    }
                }) 
            }else{
                achievementDay.settings()[0].ajax.data=_updata
                achievementDay.ajax.reload()
            }
            
        }else{
            // 月
            _updata.startDate=$('.timeyear').val()+'-'+ $('.timemonth').val()+'-01';
            _updata.endDate = undefined
            $('.js_achievement_month_wrap').removeClass('hidden')
            $('.js_achievement_day_wrap').addClass('hidden')
            $('.js_day_timewrap').addClass('hiddenim')
            $('.js_month_timewrap').removeClass('hiddenim')
            if(achievementMonth == ''){
                achievementMonth=baseFn.rpDataTables('.js_achievement_month_list',{
                    ajUrl:baseUrl.base+baseUrl.sysuser+'selectUserDaySaleList',
                    ajDataSrc:"results",
                    ajData:_updata,
                    select:true,
                    ajType:'post',
                    scrollY:windowOffsetData.tableHeight(),
                    columns:[
                        // {"data":null,defaultContent:'',className:'select-checkbox'},
                        { "data": "userNo",width:"18%",defaultContent:'',className:'imgpwrap img2p',render:function(data,type,row, meta){
                            var _img=baseUrl.tempHeadImg
                            if(baseFn.notNull(row.userImg)){
                                _img = row.userImg
                            }
                            return '<div class="datatable_img_div" data-vals="'+_img+'" style="background-image:url('+_img+')"></div>\
                                                    <div class="pwrap">\
                                                        <span>'+data+'</span>\
                                                        <span>'+row.userName+'</span>\
                                                    </div>'
                        }},
                        { "data": "subclinicName",width:"12%",defaultContent:'无'},
                        { "data": "orderTotalCost",width:"10%",defaultContent:'无'},
                        { "data": "orderPayCost",width:"10%",defaultContent:'无'},
                        { "data": "cardCost",width:"10%",defaultContent:'无'},
                        { "data": "orderCount",width:"10%",defaultContent:'无'},
                        { "data": "doctorCost",width:"10%",defaultContent:'无'},
                        { "data": "offDay",width:"10%",defaultContent:'无'},
                        // { "data": "monthTreatmentRatio",defaultContent:'无'},
                        { "data": "userId",width:"10%",defaultContent:'无',render:function(data,type,row, meta){
                            return '<a class="datatablebtn detail" href="javascript:void(0)" data-vals="'+data+'">明细</a>';

                        }}
                    ],
                    initComplete:function(){
                    },
                    drawCallback: function( settings ) {
                        $('.detail').off('click').on('click',function(){
                            zcEditData('edit')
                            var _id = $(this).data('vals')
                            baseFn.goPath('gotoCtaffManagementDetail',{userId:_id,
                                                                        startDate:($('.timeyear').val()+'-'+ $('.timemonth').val()+'-01'),
                                                                        endDate:new Date($('.timeyear').val(), $('.timemonth').val(), 0).Format("yyyy-MM-dd")})
                        })
                        //图片初始化
                        $('.js_achievement_month_list .datatable_img_div').each(function(ids,val){
                            baseFn.imgSize({
                                src: $(val).data('vals'),
                                hFn: function(res) {
                                      res.dom.css({'background-size':'auto 100%'})           
                                },
                                wFn: function(res) {
                                    res.dom.css({'background-size':'100% auto'}) 
                                },
                                ratio: 1,
                                otherData: {
                                    dom:$(val)
                                }
                            })
                        })
                    }
                })
            }else{
                achievementMonth.settings()[0].ajax.data=_updata
                achievementMonth.ajax.reload()
            }
        }
    } 
    detailSearching()
}
/*员工绩效*/
/*员工绩效详情*/
if($('.js_sysuser_achievement_detail').length == 1){
    var detailDatas={
        limit: 10,
        subclinicId:SessionData.powerSub?SessionData.powerSub:0
    }
    if(baseFn.notNull(DocData.sysUserId)){
        detailDatas.doctorId=DocData.sysUserId;
    }else{
        baseFn.infoDialog('请选择员工',function(){
            baseFn.goPath('gotoSysUserAchievements')
        })
    }
    if(baseFn.notNull(DocData.startDate)){
        detailDatas.startDate=DocData.startDate
    }
    if(baseFn.notNull(DocData.endDate)){
        detailDatas.endDate=DocData.endDate
    }
    var orderlistDT = baseFn.rpDataTables('.js_detail_list', {
        ajUrl: baseUrl.base + baseUrl.order + 'selectOrderSalePageList',
        ajDataSrc: "results",
        select: true,
        ajDataSrc:"results.rows",
        ajData:detailDatas,
        service:true,
        autoWidth: false,
        ajType: 'get',
        // displayLength:1,
        scrollY: windowOffsetData.tableHeight(),
        columns: [
            // {"data":null,defaultContent:'',className:'select-checkbox'},
            {
                data: "orderId",
                width: '15%',
                defaultContent: '',
                className: 'td2p',
                render: function (data, type, row, meta) {
                    if(!baseFn.notNull(row.orderNo)){
                        row.orderNo = '无订单号'
                    }
                    if(baseFn.notNull(row.orderTime)){
                        row.orderTime = baseFn.timestampToTime(row.orderTime)
                    }else{
                        row.orderTime = '无支付时间'
                    }
                    return '<p>订单号：' + row.orderNo + '</p><p>支付时间：' + row.orderTime + '</p>'
                    
                }
            },
            {data:"orderPayCost",width:'10%',defaultContent:'无',render:function(data,type,row,meta){
                return '￥ '+data
            }},
            {"data": "doctorCost", width: '10%', defaultContent: '无',render:function(data, type, row, meta){
                return '￥ '+ data
            }},
            {
                "data": "userName",
                width: '10%',
                defaultContent: '无',
                className: 'td2p',
                render: function (data, type, row, meta) {
                    return '<p>' + (baseFn.notNull(data)?data:'无') + '</p><p>' + (baseFn.notNull(row.userPhone)?row.userPhone:'无') + '</p>'
                }
            },
            {"data": "subclinicName", width: '10%', defaultContent: '无'},
            {
                "data": "orderId",
                width: '11%',
                serviceCost: '无',
                className: 'td2p',
                render: function (data, type, row, meta) {
                    var _txt = '<p>' + row.orderState + '</p>';
                    //权限管理 订单管理 - 13 就诊订单详情
                    if(!baseFn.getPower(13)){
                        _txt += '<a class="font_blue js_order_btn detail" href="javascript:void(0)" data-vals="' + data + '">查看订单</a>'
                    }
                    if(row.orderState == "待支付"){
                        _txt = '<p>' + row.orderState + '</p>';
                        //权限管理 订单管理 - 73 就诊订单继续支付
                        if(!baseFn.getPower(73)){
                            _txt += '<a class="font_blue js_order_btn gos" href="javascript:void(0)" data-vals="' + data + '">继续支付</a>'
                        }
                    }
                    return _txt;

                }
            }
        ],
        initComplete: function () {},
        drawCallback: function (settings) {
            $('.js_order_btn.detail').off('click').on('click', function () {
                var _id = $(this).data('vals')
                var _datas = orderlistDT.row($(this).parents('tr')).data()
                baseFn.goPath('gotoOrderDetail',{orderId:_id,orderType:0})
                
            })
        }
    })
}
/*员工绩效详情*/
/*员工列表 */
var userDTdata={
    subclinicId:SessionData.powerSub?SessionData.powerSub:0,
    limit:10,
    userStatus:DocData.userStatus,
    subclinicId:SessionData.powerSub?SessionData.powerSub:null
}


if($('.js_user_list').length != 0){
    var user = baseFn.rpDataTables('.js_user_list',{
        ajUrl:baseUrl.base+baseUrl.sysuser+'list',
        ajDataSrc:"results.list",
        select:true,
        autoWidth:false,
        //service:true,
        ajData:{
            userStatus:DocData.userStatus,
            subclinicId:SessionData.powerSub?SessionData.powerSub:null
        },
        sessionPageKey:'staffManagementListTable',
        ajType:'get',
        scrollY:windowOffsetData.tableHeight(),
        columns:[
            // {"data":null,defaultContent:'',className:'select-checkbox'},
            { "data": "userNo",defaultContent:'',className:'imgpwrap img2p',render:function(data,type,row, meta){
                var _img=baseUrl.tempHeadImg;
                if(baseFn.notNull(row.userImg)){
                    _img = row.userImg
                }
                return '<div class="datatable_img_div" data-vals="'+_img+'" style="background-image:url('+_img+')"></div>\
                        <div class="pwrap">\
                            <span>'+data+'</span>\
                            <span>'+row.userName+'</span>\
                        </div>'
            }},
            { "data": "subclinicName",defaultContent:'无'},
            { "data": "roleName",defaultContent:'无'},
            { "data": "userPhone",defaultContent:'无'},
            { "data": "createTimeStr",defaultContent:'无'},
            { "data": "userId",defaultContent:'无',render:function(data,type,row, meta){
                return '<button class="datatablebtn datatablebtnRed edit" data-vals="'+data+'">编辑</button><button class="datatablebtn detail" data-vals="'+data+'">详情</button>';

            }}
        ],
        initComplete:function(){
        },
        page: function () {
        },
        drawCallback: function( settings ) {
            $('.datatablebtn.detail').off('click').on('click',function(){
                //权限管理 62 查看员工详情
                if(baseFn.getPower(62)){
                    baseFn.infoDialog('您没有权限使用功能！')
                    return false
                }
                var _id = $(this).data('vals')
                baseFn.goPath('gotoCtaffManagementInfo',{userId:_id})
            })
            $('.datatablebtn.edit').off('click').on('click',function(){
                //权限管理 61 编辑员工
                if(baseFn.getPower(61)){
                    baseFn.infoDialog('您没有权限使用功能！')
                    return false
                }
                var _id = $(this).data('vals')
                baseFn.goPath('gotoAddSysUser',{userId:_id})
            })
            $('.js_user_list .datatable_img_div').each(function(ids,val){
                baseFn.imgSize({
                    src: $(val).data('vals'),
                    hFn: function(res) {
                          res.dom.css({'background-size':'auto 100%'})
                    },
                    wFn: function(res) {
                        res.dom.css({'background-size':'100% auto'})
                    },
                    ratio: 1,
                    otherData: {
                        dom:$(val)
                    }
                })
            })


        }
    })
}
/*员工列表 */
/*离职员工列表*/
if($('.js_user_listq').length != 0){
    DocData.userStatus=1;
    var userq = baseFn.rpDataTables('.js_user_listq',{
        ajUrl:baseUrl.base+baseUrl.sysuser+'list',
        ajDataSrc:"results.list",
        select:true,
        ajData:{
            userStatus:DocData.userStatus,
            subclinicId:SessionData.powerSub?SessionData.powerSub:null
        },
        ajType:'get',
        scrollY:windowOffsetData.tableHeight(),
        columns:[
            // {"data":null,defaultContent:'',className:'select-checkbox'},
            { "data": "userNo",defaultContent:'',className:'imgpwrap img2p',render:function(data,type,row, meta){
                var _img=baseUrl.tempHeadImg
                if(baseFn.notNull(row.userImg)){
                    _img = row.userImg
                }
                return '<div class="datatable_img_div" data-vals="'+_img+'" style="background-image:url('+_img+')"></div>\
                        <div class="pwrap">\
                            <span>'+data+'</span>\
                            <span>'+row.userName+'</span>\
                        </div>'
            }},
            { "data": "subclinicName",defaultContent:'无'},
            { "data": "userPhone",defaultContent:'无'},
            { "data": "createTimeStr",defaultContent:'无'},
            { "data": "leaveTime",defaultContent:'无',render:function(data,type,row, meta){
                return baseFn.timestampToTime(data)
            }},
            { "data": "userId",defaultContent:'无',render:function(data,type,row, meta){
                if(row.userStatus == '2'){
                    return '辞退'
                }else if(row.userStatus == 1){
                    return '<button class="datatablebtn datatablebtnRed reback" data-vals="'+data+'">恢复</button>'
                }else if(row.userStatus == 0){
                    return '成功恢复'
                }
            }}
        ],
        initComplete:function(){},
        drawCallback: function( settings ) {
            $('.datatablebtn.reback').off('click').on('click',function(){
                var _id = $(this).data('vals')
                var _tr = $(this).parents('tr')
                if(baseFn.getPower(38)){//员工管理 恢复员工
                    baseFn.infoDialog('您没有权限操作该功能')
                    return false
                }
                baseFn.dialog({
                    title:'恢复员工',
                    content:'确定要恢复该员工么？',
                    ok:function(){
                        $.post(baseUrl.base+baseUrl.sysuser+"recovery",{userId:_id,userStatus:0},function(res){
                            if(res.code == 0){
                                var _d = userq.row(_tr).data()
                                _d.userStatus=0
                                userq.row(_tr).data(_d).draw(true)
                                // userq.ajax.reload()
                                baseFn.infoDialog('成功恢复该员工')
                            }else{
                                baseFn.infoDialog(res.info)
                            }
                        })
                    },
                    cancel:true
                })
            })
            $('.js_user_listq .datatable_img_div').each(function(ids,val){
                baseFn.imgSize({
                    src: $(val).data('vals'),
                    hFn: function(res) {
                          res.dom.css({'background-size':'auto 100%'})           
                    },
                    wFn: function(res) {
                        res.dom.css({'background-size':'100% auto'}) 
                    },
                    ratio: 1,
                    otherData: {
                        dom:$(val)
                    }
                })
            })
        }
    })
}
/*离职员工列表*/ 
//请求门店列表
baseFn.rpSelect('#store',{
    url: baseUrl.base + "subclinic/selectSubclinicList",
    idKey:"subclinicId",
    textKey:'subclinicName',
    calFn:function(){
        if (baseFn.notNull($.session.get('staffManagementList'))){
            var data = JSON.parse($.session.get('staffManagementList'));
            if (baseFn.notNull(data.subclinicId)){
                $('#store').val(data.subclinicId).trigger('change');
            }
        }else {
            //权限管理 45 全部门店
            if(SessionData.powerSub){
                $("#store").val(SessionData.powerSub).trigger('change')
            }
        }
        searchData(false);
    },
    selFn:function(e){
        $('#bespeak_search_button').trigger('click')
    }
})
//点击搜索
$('#bespeak_search_button').on('click',function(){
    searchData(true);
})

function searchData(reload) {
    var _userDT = ''
    if ($('.js_user_list').length != 0) {
        _userDT = user
    } else if ($('.js_user_listq').length != 0) {
        _userDT = userq
    }else{
        // _userDT = user
        return;
    }
    var data = {
        userStatus: DocData.userStatus,
        subclinicId: $('#store').val() == -1 ? null : $('#store').val()
    }

    try {

    _userDT.settings()[0].ajax.data = data;
    $.session.set('staffManagementList', JSON.stringify(data));

    // userDTdata.subclinicId=$('#store').val()==-1?null:$('#store').val()
    _userDT.ajax.reload()
    }catch (err){
        console.log(err);
    }
}
/*评价管理 */
function gobackStaffDetail(){
    baseFn.goPath('gotoCtaffManagementInfo',{userId:DocData.sysUserId})
}
var starListDTdata = {
    userId:DocData.sysUserId,
    isReply: 1
}
var starListDT = baseFn.rpDataTables('.js_starlist',{
    ajUrl:baseUrl.base+baseUrl.sysuser+'selectUserReplyList',
    ajDataSrc:"results",
    ajData:starListDTdata,
    select:true,
    ajType:'post',
    autoWidth:false,
    scrollY:windowOffsetData.tableHeight()+windowOffsetData.brand,
    autoWidth:false,
    columns:[
        {
            data: "orderId",
            width: '15%',
            defaultContent: '',
            className: 'td2p',
            render: function (data, type, row, meta) {
                if(!baseFn.notNull(row.orderNo)){
                    row.orderNo = '无订单号'
                }
                if(baseFn.notNull(row.orderTime)){
                    row.orderTime = baseFn.timestampToTime(row.orderTime)
                }else{
                    row.orderTime = '无支付时间'
                }
                return '<p>订单号：' + row.orderNo + '</p><p>支付时间：' + row.orderTime + '</p>'
                
            }
        },
        {"data":"userName",width:"10%",defaultContent:'',className:'td2p',render:function(data,type,row, meta){
            return '<p>'+data+'</p><p>'+(baseFn.notNull(row.userPhone)?row.userPhone:'无')+'</p>'
        }},
        {"data": "replyIntegral",width:"10%",defaultContent:'',className:'td2p',render:function(data,type,row, meta){
            var _html='<p class="star_wrap">'
            for(var i=0;i<5;i++){
                var _X = ''
                var _i = (i+1)
                if(_i<= data){
                    _X = ' active'
                }
                _html += '<span class="star'+_X+'"></span>'
            }
            _html += '</p>'
            return _html
        }},
        {"data": "gentleIntegral",width:"10%",defaultContent:'',className:'td2p',render:function(data,type,row, meta){
            var _html='<p class="star_wrap">'
            for(var i=0;i<5;i++){
                var _X = ''
                var _i = (i+1)
                if(_i<= data){
                    _X = ' active'
                }
                _html += '<span class="star'+_X+'"></span>'
            }
            _html += '</p>'
            return _html
        }},
        {"data": "serviceIntegral",width:"10%",defaultContent:'',className:'td2p',render:function(data,type,row, meta){
            var _html='<p class="star_wrap">'
            for(var i=0;i<5;i++){
                var _X = ''
                var _i = (i+1)
                if(_i<= data){
                    _X = ' active'
                }
                _html += '<span class="star'+_X+'"></span>'
            }
            _html += '</p>'
            return _html
        }},
        {"data": "subclinicIntegral",width:"10%",defaultContent:'',className:'td2p',render:function(data,type,row, meta){
            var _html='<p class="star_wrap">'
            for(var i=0;i<5;i++){
                var _X = ''
                var _i = (i+1)
                if(_i<= data){
                    _X = ' active'
                }
                _html += '<span class="star'+_X+'"></span>'
            }
            _html += '</p>'
            return _html
        }},
        {"data": "replyInfo",width:"10%",defaultContent:'无'},
        {"data": "replyId",width:"10%",defaultContent:'',className:'td2p',render:function(data,type,row, meta){
            return '<p><a class="datatablebtn stardetails" data href="javascript:void(0)" data-vals="'+ data+'">修改评价</a></p>'
        }} 
    ],
    initComplete:function(){
        
    },
    drawCallback: function( settings ) {
        // var api = this.api();
        // var rows = api.rows({
        //     page: 'current'
        // }).nodes();
        // for(var r1=0;r1<rows.length;r1++){
        //     var _time = baseFn.timestampToTime(rows.data()[r1].orderTime)
        //     $(rows).eq(r1).before('<tr class="orderlistid_tr"><td colspan="8">' + _time+'&nbsp;&nbsp;&nbsp;&nbsp;'+rows.data()[r1].orderNo + '</td></tr>')
        // }
        $('.stardetails').off('click').on('click',function(){
            var _id = $(this).data('vals')
            baseFn.$post({
                url:baseUrl.sysuser+'selectUserReplyInfo',
                data:{
                    replyId:_id
                },
                calFn:function(res){
                    DocData.initStarDetail(res)
                    var _stars = baseFn.dialog({
                        title:'评价详情',
                        content:$('.starWrap'),
                        width:'30em',
                        ok:function(){
                            var _ds = baseFn.dialog({
                                title:'提交评价',
                                content:'确定提交该评价？',
                                ok:function(){
                                    baseFn.$post({
                                        url:baseUrl.sysuser + 'updateUserReplyInfo',
                                        data:{
                                            replyId:_id,
                                            replyIntegral:$('.starWrap .js_gradeNumber1').find('.active').length,
                                            gentleIntegral:$('.starWrap .js_gradeNumber2').find('.active').length,
                                            serviceIntegral:$('.starWrap .js_gradeNumber3').find('.active').length,
                                            subclinicIntegral:$('.starWrap .js_gradeNumber4').find('.active').length,
                                            replyInfo:$('.starWrap').find('textarea').val()
                                        },
                                        canNull:true,
                                        calFn:function(){
                                            baseFn.infoDialog('更改成功')
                                            starListDT.ajax.reload('')
                                        }
                                    })
                                },
                                cancel:function(){}
                            })
                        },
                        cancel:function(){}
                    })
                }
            })
            
        })
    }  
})
$('.bespeak_change_list_actve').on('click', function () {
    var thisIndex = $(this).index();
    $(this).addClass("active_bgc").siblings().removeClass("active_bgc");
    starFilterFn()
    // $('.js_tabcnt').eq(thisIndex).removeClass('hidden').siblings(".js_tabcnt").addClass('hidden');
})
$('.star').on('click',function(){
    var $this = $(this),_parent=$this.parents('.js_gradeNumber');
    var _ids = $this.data('ids')
    _parent.find('.star').each(function(ids,n){
        var _tempids = $(n).data('ids')
        if(_tempids <= _ids){
            $(n).addClass('active')
        }else{
            $(n).removeClass('active')
        }
        
    })
    _parent.siblings('p.star_text').text((Number(_ids)+1)+'.0 分')
    if(_ids>1){
        _parent.siblings('p.star_text').addClass('hs')
    }else{
        _parent.siblings('p.star_text').removeClass('hs')
    }
})
function starFilterFn(){
    var _updata={
        userId:DocData.sysUserId,
        isReply: 1
        // isReply:($('.bespeak_change_list_actve.active_bgc').attr('rel')!=0?$('.bespeak_change_list_actve.active_bgc').attr('rel'):null)
    }
    starListDT.settings()[0].ajax.data = _updata;
    starListDT.ajax.reload(null,false)
}
/*评价管理 */
//表格自适应
window.onresize = function(){
    windowOffsetData.refresh();
    var _userDT=''
    if($('.js_user_list').length != 0){
        _userDT = user
    }else if($('.js_user_listq').length != 0){
        _userDT = userq
    }
    if(baseFn.notNull(_userDT)){
        $(_userDT.table().body()).parents('.dataTables_scrollBody').css('max-height',windowOffsetData.tableHeight());
        _userDT.draw(false);
    }
    if(baseFn.notNull(achievementMonth)){
        $(achievementMonth.table().body()).parents('.dataTables_scrollBody').css('max-height',windowOffsetData.tableHeight());
        achievementMonth.draw(false);
    }
    if(baseFn.notNull(achievementDay)){
        $(achievementDay.table().body()).parents('.dataTables_scrollBody').css('max-height',windowOffsetData.tableHeight());
        achievementDay.draw(false);
    }
    if(baseFn.notNull(orderlistDT)){
        $(orderlistDT.table().body()).parents('.dataTables_scrollBody').css('max-height',windowOffsetData.tableHeight());
        orderlistDT.draw(false);
    }
}
